<%@ page import="your_car_status.Services" %>
<!DOCTYPE html>
<html>
	<head>
		<meta name="layout" content="main">
                <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
		<g:set var="entityName" value="${message(code: 'services.label', default: 'Services')}" />
		<title>New Service</title>
	</head>
	<body>
		<a href="#create-services" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
		<div id="create-services" class="content scaffold-create" role="main">
                        
			<h1><g:message code="New Service" /></h1>
                        <br/>
                        <fieldset class="buttons">
                          <b>Predefined Services Packages:</b>
                          <select id='ServicePackSelector'>
                            <option value='' selected >Select one if needed...</option>
                          <g:each in="${packages}" status="i" var="pack">
                              <option value='${pack.jsonData}'>${pack.name}</option>
                          </g:each>
                          <select>

                          <script>
                            jQuery('#ServicePackSelector').change(function(){
                              var obj=JSON.parse(this.value)
                              for(var p in obj){
                                jQuery("#"+p).val(obj[p])
                              }
                            })
                          </script>
                        </fieldset>
                        <g:if test="${flash.message}">
			<div class="message" role="status">${flash.message}</div>
			</g:if>
			<g:hasErrors bean="${servicesInstance}">
			<ul class="errors" role="alert">
				<g:eachError bean="${servicesInstance}" var="error">
				<li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message error="${error}"/></li>
				</g:eachError>
			</ul>
			</g:hasErrors>
			<g:form action="saveService" >
                                <fieldset class="form">
					<g:render template="formService"/>
				</fieldset>
				<fieldset class="buttons">
					<g:submitButton name="create" class="save" value="${message(code: 'Create')}" />
                                       <g:link class="save" action="listService" id="${carId}" >${message(code: 'Return')}</g:link>
				</fieldset>
			</g:form>
		</div>
	</body>
</html>
